From: kfraser@localhost.localdomain Date: Tue, 28 Aug 2007 15:06:32 +0000 (+0100) Subject: xend: Fix memory ballooning logic during save/restore. Should be same X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14987^2~60 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=81217a7a8d35fe341be4d0cbda4b7a44d4f1df5a;p=xen.git xend: Fix memory ballooning logic during save/restore. Should be same as during domain creation. Signed-off-by: Chris Lalancette --- diff --git a/tools/python/xen/xend/XendCheckpoint.py b/tools/python/xen/xend/XendCheckpoint.py index 6e6bb1afdd..e616c45efc 100644 --- a/tools/python/xen/xend/XendCheckpoint.py +++ b/tools/python/xen/xend/XendCheckpoint.py @@ -16,7 +16,7 @@ from xen.util.xpopen import xPopen3 import xen.util.auxbin import xen.lowlevel.xc -from xen.xend import balloon, sxp +from xen.xend import balloon, sxp, image from xen.xend.XendError import XendError, VmError from xen.xend.XendLogging import log from xen.xend.XendConfig import XendConfig @@ -181,9 +181,6 @@ def restore(xd, fd, dominfo = None, paused = False): assert store_port assert console_port - page_size_kib = xc.pages_to_kib(1) - nr_pfns = (dominfo.getMemoryTarget() + page_size_kib - 1) / page_size_kib - # if hvm, pass mem size to calculate the store_mfn image_cfg = dominfo.info.get('image', {}) is_hvm = dominfo.info.is_hvm() @@ -197,18 +194,32 @@ def restore(xd, fd, dominfo = None, paused = False): pae = 0 try: - shadow = dominfo.info['shadow_memory'] + restore_image = image.create(dominfo, dominfo.info['image'], + dominfo.info['device']) + memory = restore_image.getRequiredAvailableMemory( + dominfo.info['memory'] * 1024) + maxmem = restore_image.getRequiredAvailableMemory( + dominfo.info['maxmem'] * 1024) + shadow = restore_image.getRequiredShadowMemory( + dominfo.info['shadow_memory'] * 1024, + dominfo.info['maxmem'] * 1024) + log.debug("restore:shadow=0x%x, _static_max=0x%x, _static_min=0x%x, ", dominfo.info['shadow_memory'], dominfo.info['memory_static_max'], dominfo.info['memory_static_min']) - balloon.free(xc.pages_to_kib(nr_pfns) + shadow * 1024) + # Round shadow up to a multiple of a MiB, as shadow_mem_control + # takes MiB and we must not round down and end up under-providing. + shadow = ((shadow + 1023) / 1024) * 1024 - shadow_cur = xc.shadow_mem_control(dominfo.getDomid(), shadow) - dominfo.info['shadow_memory'] = shadow_cur + # set memory limit + xc.domain_setmaxmem(dominfo.getDomid(), maxmem) - xc.domain_setmaxmem(dominfo.getDomid(), dominfo.getMemoryMaximum()) + balloon.free(memory + shadow) + + shadow_cur = xc.shadow_mem_control(dominfo.getDomid(), shadow / 1024) + dominfo.info['shadow_memory'] = shadow_cur cmd = map(str, [xen.util.auxbin.pathTo(XC_RESTORE), fd, dominfo.getDomid(), @@ -220,7 +231,7 @@ def restore(xd, fd, dominfo = None, paused = False): forkHelper(cmd, fd, handler.handler, True) # We don't want to pass this fd to any other children -- we - # might need to recover ths disk space that backs it. + # might need to recover the disk space that backs it. try: flags = fcntl.fcntl(fd, fcntl.F_GETFD) flags |= fcntl.FD_CLOEXEC